package com.lottery.ruok.lottrey.activity;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.android.lib.dialog.BottomDialog;
import com.android.lib.dialog.Builder;
import com.applozic.mobicomkit.uiwidgets.conversation.messageUtils.ChatRecordUtils;
import com.applozic.mobicomkit.uiwidgets.conversation.messageUtils.SearchRecordUtils;
import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.adapter.PrizePeopleAdapter;
import com.lottery.ruok.lottrey.chat.RongCloudChatActivityHelper;
import com.lottery.ruok.lottrey.chat.event.manager.UnReadMessageManager;
import com.lottery.ruok.lottrey.eventbusObject.AddChatUser;
import com.lottery.ruok.lottrey.eventbusObject.BubbleChange;
import com.lottery.ruok.lottrey.eventbusObject.ChatRecodeEventMessage;
import com.lottery.ruok.lottrey.retrofitModule.RetrofitBase;
import com.lottery.ruok.lottrey.retrofitModule.RxHelper;
import com.lottery.ruok.lottrey.retrofitModule.RxSubscribe;
import com.lottery.ruok.lottrey.retrofitModule.request.AddChatAdminResquest;
import com.lottery.ruok.lottrey.retrofitModule.request.GetRechargeBankRequest;
import com.lottery.ruok.lottrey.retrofitModule.request.GetRongUserInfoRequest;
import com.lottery.ruok.lottrey.retrofitModule.request.GetRoomUsersRequest;
import com.lottery.ruok.lottrey.retrofitModule.request.ResumeChatUserRequest;
import com.lottery.ruok.lottrey.retrofitModule.request.UpdateRoomNameRequest;
import com.lottery.ruok.lottrey.retrofitModule.response.GetRongUserInfoReponse;
import com.lottery.ruok.lottrey.retrofitModule.response.GetRoomUsersResponse;
import com.lottery.ruok.lottrey.retrofitModule.response.OperationSuccessResponse;
import com.lottery.ruok.lottrey.userInfo.UserInfo;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

import de.hdodenhof.circleimageview.CircleImageView;
import glideHelp.GlideHelper;
import io.rong.imkit.RongIM;
import io.rong.imkit.manager.IUnReadMessageObserver;
import io.rong.imkit.userInfoCache.RongUserInfoManager;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import ui.NavigateBar;
import utils.Utils;

/*
 * 群成员
 * */

public class NewChannelInfoActivity extends BaseActivity {

    @BindView(R.id.list)
    ListView list;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout mRefreshLayout;
    @BindView(R.id.navigateBar)
    NavigateBar navigateBar;
    private PrizePeopleAdapter prizePeopleAdapter;
    private int mIndex = 0;

    private TextView group_name;
    private CircleImageView grouppic;
    Handler myHandler = new Handler() {
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
                case 1:
                    setConversationRecord();
                    break;
            }
            super.handleMessage(msg);
        }
    };
    private List<Conversation> conversationsList = new ArrayList<>();
    private List<GetRoomUsersResponse.ListBean> RoomUsersResponsesList = new ArrayList<>();
    private ArrayList<GetRoomUsersResponse.ListBean> chatRecodeList = new ArrayList<>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_channel);
        ButterKnife.bind(this);

        EventBus.getDefault().register(this);

        init();
        UnReadMessageManager.getInstance().registerPrivateUnReadMessageCountChangedObserver(new IUnReadMessageObserver() {
            @Override
            public void onCountChanged(int i) {
                if (prizePeopleAdapter != null) {
                    prizePeopleAdapter.notifyDataSetChanged();
                }
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(AddChatUser addChatUser) {
        getList(0);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(BubbleChange bubbleChange) {
        prizePeopleAdapter.notifyDataSetChanged();
    }

   /* @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(ChatRecodeEventMessage chatRecodeEventMessage) {
        if (chatRecodeEventMessage == null) {
            return;
        }
        int messageType = chatRecodeEventMessage.getMessageType();
        GetRoomUsersResponse.ListBean bean = chatRecodeEventMessage.getData();
        if (messageType == ChatRecodeEventMessage.MESSAGE_TYPE_ADD) {
            if (bean.getDataType() == 1) {
                List<GetRoomUsersResponse.ListBean> list = prizePeopleAdapter.getList();
                if (ChatRecordUtils.size() > 10) {
                    //去除旧的
                    for (int i = 0; i < list.size(); i++) {
                        GetRoomUsersResponse.ListBean listBean = list.get(i);
                        if (listBean != null) {
                            if (listBean.getDataType() == 0 && i == 0) {
                                break;
                            } else if (listBean.getDataType() == 0 && i > 0) {
                                list.remove(i - 1);
                                break;
                            }
                        }
                    }
                    //添加新的
                    list.add(0, bean);

                } else {
                    list.add(0, bean);
                }
                prizePeopleAdapter.notifyDataSetChanged();
            }
        } else if (messageType == ChatRecodeEventMessage.MESSAGE_TYPE_DELETE) {
            prizePeopleAdapter.remove(bean);
        }

    }*/


    @Override
    protected void onDestroy() {
        super.onDestroy();

        EventBus.getDefault().unregister(this);
    }

    private void init() {

        navigateBar.setOnOperateClickListener(new NavigateBar.OnOperateClickListener() {
            @Override
            public void onOperateClick(View view) {
                SearchChannelActivity.startActivity(NewChannelInfoActivity.this);

            }
        });
       /* BGARefreshViewHolder refreshViewHolder = new BGANormalRefreshViewHolder(this, true);
        swipeRefreshLayout.setRefreshViewHolder(refreshViewHolder);

        swipeRefreshLayout.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
            @Override
            public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
                getList(mIndex);
                return true;
            }

            @Override
            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
                getList(0);
            }
        });*/

        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                mRefreshLayout.setEnableRefresh(true);//启用刷新
                getList(0);
            }
        });
        mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(RefreshLayout refreshlayout) {
                mRefreshLayout.setEnableLoadMore(true);//启用加载
                getList(mIndex);
            }
        });

        View header = getLayoutInflater().inflate(R.layout.header_new_channel, null);
        FrameLayout frameLayout = header.findViewById(R.id.frame);
        list.addHeaderView(header);
        View view = header.findViewById(R.id.add);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //sendAnalyticMsg("lottery_" + MobiComConversationFragment.ANALYTIC_VERSION + "_chat_group_add_groupmember");

                Intent intent = new Intent(NewChannelInfoActivity.this, AddNewUserActivity.class);
                startActivity(intent);
            }
        });
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                final int position = i - 1;
                if (position >= 0) {
                    final GetRoomUsersResponse.ListBean listBean = prizePeopleAdapter.getList().get(position);
                    if (!UserInfo.getUsername().equals(listBean.getUsername())) {
                        Builder builder = new Builder(NewChannelInfoActivity.this);//首先自己不能和自己聊天，已经是管理员的人不能再被设为管理员，自己也不能移除自己
                        builder.addOption("私聊", Color.parseColor("#007aff"), new BottomDialog.OnOptionClickListener() {
                            @Override
                            public void onOptionClick() {
                                RongCloudChatActivityHelper.startPrivateChat(NewChannelInfoActivity.this, listBean.getRy_id(), listBean.getNickname());
                            }
                        });
                        if (listBean.getChatroom_role() != null && listBean.getChatroom_role().equals("1")) {
                            builder.addOption("选定为管理员", Color.parseColor("#007aff"), new BottomDialog.OnOptionClickListener() {
                                @Override
                                public void onOptionClick() {

                                    Utils.createDialog(NewChannelInfoActivity.this, "确定选定用户" + listBean.getNickname() + "为管理员",
                                            "取消", "确定",
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {

                                                }
                                            }, new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {
                                                    RetrofitBase.getRetrofit().create(AddChatAdminResquest.class)
                                                            .getResult(UserInfo.getToken(), listBean.getUsername(), 1)
                                                            .compose(RxHelper.<OperationSuccessResponse>handleResult())
                                                            .subscribe(new RxSubscribe<OperationSuccessResponse>(NewChannelInfoActivity.this) {
                                                                @Override
                                                                protected void _onNext(OperationSuccessResponse operationSuccessResponse) {
                                                                    Utils.showToast(operationSuccessResponse.getMsg());

                                                                  /*  listBean.setChatroom_role("3");
                                                                    prizePeopleAdapter.notifyDataSetChanged();*/
                                                                    getList(0);
                                                                }

                                                                @Override
                                                                protected boolean showDialog() {
                                                                    return true;
                                                                }
                                                            });
                                                }
                                            });
                                }
                            });
                        }
                        //删除管理员//1  聊天室 1=会员[默认] 2=超级管理员 3=普通管理员 5=代理总代股东
                        if (listBean.getChatroom_role() != null && !listBean.getChatroom_role().equals("2")) {
                            if (listBean.getChatroom_role().equals("3") || listBean.getChatroom_role().equals("5")) {
                                builder.addOption("取消管理员", Color.parseColor("#007aff"), new BottomDialog.OnOptionClickListener() {
                                    @Override
                                    public void onOptionClick() {

                                        Utils.createDialog(NewChannelInfoActivity.this, "确定取消用户" + listBean.getNickname() + "管理员权限",
                                                "取消", "确定",
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialogInterface, int i) {

                                                    }
                                                }, new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialogInterface, int i) {
                                                        RetrofitBase.getRetrofit().create(AddChatAdminResquest.class)
                                                                .getResult(UserInfo.getToken(), listBean.getUsername(), 0)
                                                                .compose(RxHelper.<OperationSuccessResponse>handleResult())
                                                                .subscribe(new RxSubscribe<OperationSuccessResponse>(NewChannelInfoActivity.this) {
                                                                    @Override
                                                                    protected void _onNext(OperationSuccessResponse operationSuccessResponse) {
                                                                        Utils.showToast(operationSuccessResponse.getMsg());

                                                                       /* listBean.setChatroom_role("1");
                                                                        prizePeopleAdapter.notifyDataSetChanged();*/
                                                                        getList(0);
                                                                    }

                                                                    @Override
                                                                    protected boolean showDialog() {
                                                                        return true;
                                                                    }
                                                                });
                                                    }
                                                });
                                    }
                                });
                            }
                        }
                        //如果是超级管理员，无法被移除
                        if (listBean.getChatroom_role() != null && !listBean.getChatroom_role().equals("3")) {
                            builder.addOption("移除此成员", Color.parseColor("#007aff"), new BottomDialog.OnOptionClickListener() {
                                @Override
                                public void onOptionClick() {
                                    Utils.createDialog(NewChannelInfoActivity.this, "确定把用户" + listBean.getNickname() + "从群里移除",
                                            "取消", "确定",
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {

                                                }
                                            }, new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {
                                                    RetrofitBase.getRetrofit().create(ResumeChatUserRequest.class)
                                                            .getResult(UserInfo.getToken(), listBean.getRy_id(), 0)
                                                            .compose(RxHelper.<OperationSuccessResponse>handleResult())
                                                            .subscribe(new RxSubscribe<OperationSuccessResponse>(NewChannelInfoActivity.this) {
                                                                @Override
                                                                protected void _onNext(OperationSuccessResponse operationSuccessResponse) {
                                                                    Utils.showToast(operationSuccessResponse.getMsg());

                                                                   /* prizePeopleAdapter.getList().remove(position);
                                                                    prizePeopleAdapter.notifyDataSetChanged();*/
                                                                    getList(0);
                                                                }

                                                                @Override
                                                                protected boolean showDialog() {
                                                                    return true;
                                                                }
                                                            });
                                                }
                                            });
                                }
                            });
                        }


                        if (listBean != null && listBean.getDataType() != 0) {
                            builder.addOption("删除该记录", Color.parseColor("#ff0000"), new BottomDialog.OnOptionClickListener() {
                                @Override
                                public void onOptionClick() {
                                    Utils.createDialog(NewChannelInfoActivity.this, "确定把用户" + listBean.getNickname() + "的记录移除",
                                            "取消", "确定",
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {

                                                }
                                            }, new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {
                                                    if (listBean.getDataType() == 1) {
                                                        //删除聊天记录
                                                        ChatRecordUtils.delete(listBean.getUsername());
                                                        prizePeopleAdapter.remove(listBean);
                                                        //   RongIM.getInstance().clearMessages(Conversation.ConversationType.PRIVATE,listBean.getRy_id());

                                                        RongIM.getInstance().removeConversation(Conversation.ConversationType.PRIVATE, listBean.getRy_id(), new RongIMClient.ResultCallback<Boolean>() {
                                                            @Override
                                                            public void onSuccess(Boolean aBoolean) {

                                                            }

                                                            @Override
                                                            public void onError(RongIMClient.ErrorCode errorCode) {

                                                            }
                                                        });
                                                    } else if (listBean.getDataType() == 2) {
                                                        //删除搜索记录
                                                        SearchRecordUtils.delete(listBean.getUsername());
                                                    }
                                                }
                                            });
                                }
                            });
                        }

                        builder.create().show();
                    } else {
                        Utils.showToast("这是你本人噢");
                    }
                }
            }
        });
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
        layoutParams.height = (int) (Utils.getWindowDisplay(this).widthPixels * 160f / 375);
        frameLayout.setLayoutParams(layoutParams);
        grouppic = header.findViewById(R.id.grouppic);
        group_name = header.findViewById(R.id.group_name);
        LinearLayout lottery_name = header.findViewById(R.id.lottery_name);
        lottery_name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                final EditText editText = new EditText(NewChannelInfoActivity.this);
                editText.setText(group_name.getText().toString());
                editText.setTextColor(getResources().getColor(R.color.font_black));
                editText.setSelection(group_name.getText().toString().length());
                final AlertDialog dialog = new AlertDialog.Builder(NewChannelInfoActivity.this)
                        .setTitle("修改群昵称")//设置提示内容
                        .setView(editText)
                        //确定按钮
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                RetrofitBase.getRetrofit().create(UpdateRoomNameRequest.class)
                                        .getResult(UserInfo.getToken(), UserInfo.getRoomId(), group_name.getText().toString(), editText.getText().toString())
                                        .compose(RxHelper.<OperationSuccessResponse>handleResult())
                                        .subscribe(new RxSubscribe<OperationSuccessResponse>(NewChannelInfoActivity.this) {
                                            @Override
                                            protected void _onNext(OperationSuccessResponse removeFavorResponse) {
                                                group_name.setText(editText.getText().toString());
                                            }

                                            @Override
                                            protected boolean showDialog() {
                                                return true;
                                            }
                                        });
                            }
                        })
                        //取消按钮
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {

                            }
                        })
                        .create();//创建对话框
                dialog.show();//显示对话框
                dialog.getButton(Dialog.BUTTON_NEGATIVE).setTextColor(NewChannelInfoActivity.this.getResources().getColor(com.android.lib.R.color.purples));
                dialog.getButton(Dialog.BUTTON_POSITIVE).setTextColor(NewChannelInfoActivity.this.getResources().getColor(com.android.lib.R.color.purples));
            }
        });


    }

    @Override
    protected void onResume() {
        super.onResume();
        getList(0);
        if (prizePeopleAdapter != null) {
            prizePeopleAdapter.notifyDataSetChanged();
        }
    }


    private void getList(final int index) {
        RetrofitBase.getRetrofit().create(GetRoomUsersRequest.class)
                .getResult(UserInfo.getToken(), UserInfo.getRoomId() , null, 10, index)
                .compose(RxHelper.<GetRoomUsersResponse>handleResult())
                .subscribeWith(new RxSubscribe<GetRoomUsersResponse>(this) {
                    @Override
                    protected void _onNext(final GetRoomUsersResponse getRoomUsersResponses) {

                        if (getRoomUsersResponses != null) {
                            RoomUsersResponsesList.clear();
                            RoomUsersResponsesList.addAll(getRoomUsersResponses.getList());

                            group_name.setText(getRoomUsersResponses.getRoom_name());
                            GlideHelper.loadImage(NewChannelInfoActivity.this, getRoomUsersResponses.getAvatar(), grouppic);

                            mIndex = index + 10;

                            if (index == 0) {
                                RongIMClient.getInstance().getConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {
                                    @Override
                                    public void onSuccess(List<Conversation> conversations) {
                                        conversationsList.clear();
                                        if (conversations != null) {
                                            conversationsList.addAll(conversations);
                                        }
                                        //县城进程啊
                                        android.os.Message nessage = new android.os.Message();
                                        nessage.what = 1;
                                        myHandler.sendMessage(nessage);

                                    }

                                    @Override
                                    public void onError(RongIMClient.ErrorCode errorCode) {

                                    }
                                }, Conversation.ConversationType.PRIVATE);

                            } else {

                                prizePeopleAdapter.getList().addAll(getRoomUsersResponses.getList());
                                prizePeopleAdapter.notifyDataSetChanged();
                                mRefreshLayout.finishLoadMore();
                            }

                            navigateBar.setCenterTitle("群成员(" + getRoomUsersResponses.getCount() + ")");
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);

                        if (index == 0) {
                            mRefreshLayout.finishRefresh();
                        } else {
                            mRefreshLayout.finishLoadMore();
                        }
                    }

                    @Override
                    protected boolean showDialog() {
                        return true;
                    }
                });
    }

    private void setConversationRecord() {
        final List<GetRoomUsersResponse.ListBean> listBeans = new ArrayList<>();
        if (conversationsList.size() > 0) {
            String rongId = "";
            int converSize = 0;
            if (conversationsList.size() < 11) {
                converSize = conversationsList.size();
            } else {
                converSize = 10;
            }
            for (int i = 0; i < converSize; i++) {
                Conversation conversationBean = conversationsList.get(i);
                if (i == 0) {
                    rongId = conversationsList.get(i).getTargetId();
                } else {
                    rongId = rongId + "," + conversationsList.get(i).getTargetId();
                }
            }

            RetrofitBase.getRetrofit().create(GetRongUserInfoRequest.class).getResult(null, null, rongId)
                    .compose(RxHelper.<GetRongUserInfoReponse>handleResult())
                    .subscribe(new RxSubscribe<GetRongUserInfoReponse>(this) {
                        @Override
                        protected void _onNext(GetRongUserInfoReponse getRongUserInfoReponses) {

                            if (getRongUserInfoReponses != null) {

                                for (int i = 0; i < getRongUserInfoReponses.getList().size(); i++) {
                                    GetRongUserInfoReponse.ListBean bean = getRongUserInfoReponses.getList().get(i);
                                    GetRoomUsersResponse.ListBean listBean = new GetRoomUsersResponse.ListBean();

                                    listBean.setChatroom_role(bean.getChatroom_role());
                                    listBean.setDataType(1);
                                    listBean.setNickname(bean.getNickname());
                                    listBean.setUsername(bean.getUsername());
                                    listBean.setAvatar(bean.getAvatar());
                                    listBean.setRy_id(bean.getRy_id());
                                    listBean.setOnline_status(bean.getOnline_status());
                                    listBeans.add(listBean);


                                }

                            }
                            chatRecodeList.clear();
                            chatRecodeList.addAll(listBeans);
                            chatRecodeList.addAll(RoomUsersResponsesList);
                            prizePeopleAdapter = new PrizePeopleAdapter(NewChannelInfoActivity.this, chatRecodeList);
                            list.setAdapter(prizePeopleAdapter);
                            mRefreshLayout.finishRefresh();

                        }

                        @Override
                        public void onError(Throwable e) {
                            super.onError(e);
                        }

                        @Override
                        protected boolean showDialog() {
                            return true;
                        }
                    });

        } else {

            chatRecodeList.clear();
            chatRecodeList.addAll(RoomUsersResponsesList);
            prizePeopleAdapter = new PrizePeopleAdapter(NewChannelInfoActivity.this, chatRecodeList);
            list.setAdapter(prizePeopleAdapter);
            mRefreshLayout.finishRefresh();

        }


    }

  /*  private List<GetRoomUsersResponse.ListBean> createConversation(List<Conversation> conversations) {
        final List<GetRoomUsersResponse.ListBean> listBeans = new ArrayList<>();

        if (conversations != null) {
          *//*  Iterator<Conversation> iterator = conversations.iterator();
            while (iterator.hasNext()) {
                Conversation conversation = iterator.next();
                if (conversation != null) {
                    GetRoomUsersResponse.ListBean listBean = new GetRoomUsersResponse.ListBean();
                    listBean.setAvatar(conversation.getPortraitUrl());
                    listBean.setChatroom_role("1");
                    io.rong.imlib.model.UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId());
                    listBean.setDataType(1);
                    if (userInfo != null) {
                        listBean.setNickname(userInfo.getName());
                        listBean.setAvatar(userInfo.getPortraitUri().toString());
                        listBean.setRy_id(userInfo.getUserId());
                    }
                    listBean.setDataType(1);
                    listBean.setNickname(conversation.getSenderUserName());
                    listBean.setAvatar(conversation.getPortraitUrl());
                    listBean.setChatroom_block(conversation.getSentStatus().getValue());
                    listBean.setRy_id(conversation.getSenderUserId());
                    listBeans.add(listBean);

                }
            }*//*
            String rongId="";

                for (int i = 0; i < conversations.size(); i++) {
                    Conversation conversationBean = conversations.get(i);
                    if (i == 0) {
                        rongId = conversations.get(i).getSenderUserId();
                    } else {
                        rongId = rongId + "," +conversations.get(i).getSenderUserId();
                    }
                }

              RetrofitBase.getRetrofit().create(GetRongUserInfoRequest.class).getResult(null,null,"3515")
                      .compose(RxHelper.<ArrayList<GetRongUserInfoReponse>>handleResult())
                      .subscribe(new RxSubscribe<ArrayList<GetRongUserInfoReponse>  >(this) {
                          @Override
                          protected void _onNext(ArrayList<GetRongUserInfoReponse> getRongUserInfoReponses) {

 *//*GetRoomUsersResponse.ListBean listBean = new GetRoomUsersResponse.ListBean();
                    listBean.setAvatar(conversation.getPortraitUrl());
                    listBean.setChatroom_role("1");
                    io.rong.imlib.model.UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId());
                    listBean.setDataType(1);
                    if (userInfo != null) {
                        listBean.setNickname(userInfo.getName());
                        listBean.setAvatar(userInfo.getPortraitUri().toString());
                        listBean.setRy_id(userInfo.getUserId());
                    }
                  *//**//*  listBean.setDataType(1);
                    listBean.setNickname(conversation.getSenderUserName());
                    listBean.setAvatar(conversation.getPortraitUrl());
                    listBean.setChatroom_block(conversation.getSentStatus().getValue());
                    listBean.setRy_id(conversation.getSenderUserId());*//**//*
                    listBeans.add(listBean);*//*
                              if (getRongUserInfoReponses!=null){

                                  for (int i = 0; i < getRongUserInfoReponses.size(); i++) {
                                      GetRongUserInfoReponse bean = getRongUserInfoReponses.get(i);
                                      GetRoomUsersResponse.ListBean listBean = new GetRoomUsersResponse.ListBean();

                                      listBean.setChatroom_role(bean.getOnline_status());
                                      listBean.setDataType(1);
                                      listBean.setNickname(bean.getNickname());
                                      listBean.setAvatar(bean.getAvatar());
                                      listBean.setRy_id(bean.getRy_id());
                                      listBeans.add(listBean);


                                  }

                              }


                          }

                          @Override
                          protected boolean showDialog() {
                              return false;
                          }
                      });




        }
        return listBeans;
    }*/
}
